$(function() {
    var f = $("#hidGoodsID").val();
    var p = $("#hidCodeID").val();
    var m = $("#hidShowTime").val() == "1";
    if (m) {
    } else {
        var d = function(q) {
            $.PageDialog.fail(q);
        };
        var h = function(q) {
            $.PageDialog.ok("<s></s>" + q);
        };
        var l = function(r) {
			$('#login_ui').fadeIn();
			$('#zom').css({
				'width' : $(window).width(),
				'height' : $(window).height()
			}).show();
			$('#login-ui-close').click(function(){
				$('#login_ui').fadeOut('fast',function(){
					$('#zom').hide();
				});
			});
		$('#submit').click(function(){
			var checkcode = $('#checkcode').val();
			var p = $("#hidCodeID").val();
			$.ajax({
				type : 'POST',
				url : config.url+'/app.php?act=jointeamcheck&goods_id='+p,
				dataType : 'json',
				async : false,
				beforeSend : function(){
					if(checkcode == ''){
						d('请输入邀请码');
						return false;
					}
				},
				data : {code : checkcode},
				success : function(res){
					if(res['code'] == 1){
						d(res['msg']);
						return false;
					}else if(res['code'] == 0){
						h(res['msg']);
						var price = $('#price').val();
						join_addCart(p,price,1);
						appClose('commissions',api);
						appClose('userindex',api);
						randomSwitchBtn('join_cart',api);
					}
				}
			});
			return false;
		});
        };
        var i = function() {
            var q = $("#btnBuyBox");
            q.children("a").eq(0).click(function() {
                l(1);
            });
            q.children("a").eq(1).click(function() {
                l(0);
            });
        };
        i();
        var g = $("#divAutoRTime");
        if (g.length > 0) {
            var o = g.attr("time");
            if (o) {
                var e = parseInt(o);
                g.html("<p><span>限时揭晓</span>剩余时间：<em>00</em>时<em>00</em>分<em>00</em>秒</p>");
                var k = function() {
                };
                /*
                Base.getScript(Gobal.Skin + "/js/mobile/CountdownFun.js",
                function() {
                    g.countdowntime(e, k);
                });
                */
				//获取当前商品
                var n = function() {			
				    GetJPData(config.url, "ajax", "getCodeState/" + p ,                   
                    function(q) {
                        if (q.Code == 0) {
                            k();
                        }
                    });
                };
                setInterval(n, 30000);
            } else {
                var j = g.attr("timeAlt").split("-");
                g.html("<p><span>限时揭晓</span>揭晓时间：<em>" + j[0] + "</em>月<em>" + j[1] + "</em>日<em>" + j[2] + "</em>点</p>");
            }
        }
        var c = function(q) {
            if (q && q.stopPropagation) {
                q.stopPropagation();
            } else {
                window.event.cancelBubble = true;
            }
        };
        var b = $("#prevPeriod");
        b.click(function() {
            location.href = config.url+"/mobile/mobile/tdataserver/" + $(this).attr("codeid");
        }).find("li.fl").click(function(q) {
            c(q);
            location.href = config.url+"/mobile/mobile/userindex/" + $(this).parent().attr("uweb");
        });
        b.find("em.blue").addClass("orange").click(function(q) {
            c(q);
            location.href = config.url+"/mobile/mobile/userindex/" + $(this).parent().parent().parent().attr("uweb");
        });
    }
});